/**
 * Created with JetBrains WebStorm. User: Administrator Date: 13-11-10 Time: 下午1:44 To change this template use File |
 * Settings | File Templates.
 */
Ext.define("byb.store.DictStore", {
    extend: "Ext.data.Store",
    autoLoad: false,
    model: "byb.model.DictModel",
    id: "dictStore",
    constructor: function() {
        if (arguments && arguments.length > 0) {
            this.data = this.getDataByType(arguments[0]);
            if (arguments[0].all) {
                var all = [{
                    name: byb.Constant.AllEmployee,
                    id: 0
                }];
                this.data = all.concat(this.data);
            }
        }
        this.callParent(arguments);
    },
    getDataByType: function(params) {
        if (params.type) {
            var cookie= Ext.util.Cookies.get("loginCookie");
            if(cookie){
                var admCode = byb.Constant.Factory("AdmCode");
                return admCode.get(params.type);
            }
        }
    },
    setCompoDefaultValue:function(name) {
        var combo= Ext.ComponentQuery.query("combo[name='"+name+"']")[0];
        if(combo){
            combo.setValue(this.first().data.id);
        }
    }
});
